package com.algo.server;

import com.algo.core.RapidSeverConfig;
import com.algo.core.RapidSeverConfigLoader;
import com.algo.core.Container;
import org.apache.log4j.Logger;

/**
 * 网关启动类
 */
public class Bootstrap {

    private static final Logger logger = Logger.getLogger(Bootstrap.class);

    public static void main(String[] args) {
        // 加载配置
        RapidSeverConfig rapidSeverConfig = RapidSeverConfigLoader.getInstance().load(args);

        try {
            // 创建容器
            Container container = new Container(rapidSeverConfig);

            // 启动容器
            container.start();

            Runtime.getRuntime().addShutdownHook(new Thread() {
                @Override
                public void run() {
                    container.shutdown();
                }
            });
        } catch (Exception e) {
            logger.info("create container error ", e);
        }

    }

}
